package com.cf.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;

import java.util.LinkedHashMap;
import java.util.List;

@Mapper
public interface SinovatMapper {
    @Select("SELECT ROW_NUMBER() OVER(ORDER BY T0.ITEMCODE) row,T0.DocEntry , "
            + " T1.CardCode,T1.CardName,T1.DocDate ,T1.DocTotal ,T1.Comments, "
            + " SUBSTRING(T2.SlpName,8,3) SlpName, T4.NumAtCard,"
            + " T0.WhsCode,T0.ItemCode,T0.Dscription,T0.Quantity,T0.LineTotal, "
            + " T0.PriceAfVAT,T0.Price ,'PCS' as unit " + " FROM ODLN T1 "
            + " INNER JOIN DLN1 T0 ON T0.DocEntry =T1.DocEntry  "
            + " INNER JOIN OSLP T2 ON T1.SlpCode =T2.SlpCode  "
            + " INNER JOIN RDR1 T3 ON T3.DocEntry =T0.BaseEntry AND T3.LineNum =T0.BaseLine "
            + " INNER JOIN ORDR T4 ON T3.DocEntry =T4.DocEntry "
            + " WHERE T0.DocEntry =#{DocEntry}")
    List<LinkedHashMap<String, Object>> delivery(Integer DocEntry);

    @Select("{CALL testPrd(#{yearly,mode=IN})}")
    @Options(statementType = StatementType.CALLABLE)
    String test(@Param("yearly") Integer yearly);

}
